package com.project.service.impl;

import java.util.List;
import java.util.Map;

import com.project.entity.UnitInfo;
import com.project.entity.UnitInfoExample;
import com.project.mapper.UnitInfoMapper;
import com.project.service.UnitInfoManage;
/**
 * 单位信息服务实现类
 * 作者：甘雨
 **/
public class UnitInfoManageService implements UnitInfoManage {
	private UnitInfoMapper unitInfoMapper;
	

	public UnitInfoMapper getUnitInfoMapper() {
		return unitInfoMapper;
	}

	public void setUnitInfoMapper(UnitInfoMapper unitInfoMapper) {
		this.unitInfoMapper = unitInfoMapper;
	}

	public int InsertUnitInfo(UnitInfo unitInfo) {
		this.unitInfoMapper.insert(unitInfo);
		return 0;
	}

	public void deleteUnitInfoById(Integer unitInfoId) {
		this.unitInfoMapper.deleteByPrimaryKey(unitInfoId);

	}

	public List<UnitInfo> getAllUnitInfo() {
		UnitInfoExample example =new UnitInfoExample();		
		return this.unitInfoMapper.selectByExample(example);
	}

	public UnitInfo getById(Integer unitInfoId) {
		return this.unitInfoMapper.selectByPrimaryKey(unitInfoId);
	}

	public void updateUnitInfo(UnitInfo unitInfo) {
		this.unitInfoMapper.updateByPrimaryKey(unitInfo);

	}
	
	public int countAllUnit(){
		UnitInfoExample example =new UnitInfoExample();		
		return this.unitInfoMapper.countByExample(example);
	}

	public int countUnit(Map<String, String> map) {
		// TODO Auto-generated method stub
		int i;
		try{
			i = this.unitInfoMapper.countUnit(map);
		} catch(Exception e){
			i = -1;
			e.printStackTrace();
		}
		return i;
	}

	public List<UnitInfo> getAllUnit(Map<String, String> map) {
		// TODO Auto-generated method stub
		List<UnitInfo> list = this.unitInfoMapper.getAllUnit(map);
		return list;
	}

	public List<UnitInfo> conditionSelect(UnitInfo record, Integer start,
			Integer limit) {
		List<UnitInfo> list = this.unitInfoMapper.conditionSelect(record, start, limit);
		return list;
	}

}
